<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.prime.com.tr/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <link href="#{man.baseUrl}resources/css/default.css" rel="stylesheet" type="text/css" />
        <link href="#{man.baseUrl}resources/css/cssLayout.css" rel="stylesheet" type="text/css" />
        <title>Facelets Template</title>
    </h:head>

    <h:body>

        <div id="top">
            <ui:insert name="top">
                <h:form id="topForm" >
                    <p:menubar effectDuration="50" autoSubmenuDisplay="true" model="#{man.menuModel}" />
                    <p:growl id="messages"/>
                </h:form>
            </ui:insert>
        </div>

        <p:layout style="width:980px;height:500px;">

            <p:layoutUnit position="left" width="170" resizable="false"
                          minWidth="50" maxWidth="200" collapsible="true">
                <ui:insert name="left"></ui:insert>
            </p:layoutUnit>

            <p:layoutUnit position="center" id="layoutCenter">
                <h:outputLink id="lnk" value="#" styleClass="right">
                    <p:printer target="layoutCenter" />
                    <p:graphicImage value="/images/print.png" />
                </h:outputLink>
                <ui:insert name="center">Standardní služby</ui:insert>
            </p:layoutUnit>

        </p:layout>

        <p:growl id="growl" showDetail="true" life="3000" />
        <p:dialog id="dialog" header="Login" widgetVar="dlgLogin">
            <h:form>

                <h:panelGrid columns="2" cellpadding="5">
                    <h:outputLabel for="username" value="Email: *" />
                    <p:inputText value="#{loginBean.user.email}"
                                 id="username" required="true" label="username" />
                    <h:outputLabel for="password" value="Heslo * " />
                    <h:inputSecret value="#{loginBean.user.passwd}"
                                   id="password" required="true" label="password" />

                    <f:facet name="footer">
                        <p:commandButton value="Login" update="growl"
                                         actionListener="#{loginBean.login}"
                                         oncomplete="handleLoginRequest(xhr, status, args)"/>
                    </f:facet>
                </h:panelGrid>

            </h:form>
        </p:dialog>



        <script type="text/javascript">
                function handleLoginRequest(xhr, status, args) {
                        if(args.validationFailed || !args.loggedIn) {
                                jQuery('#dialog').parent().effect("shake", { times:3 }, 100);
                        } else {
                                dlgLogin.hide();
                                jQuery('#loginLink').fadeOut();
                        }
                }
        </script>

        <div id="bottom">
            <ui:insert name="bottom">Stránky fyx</ui:insert>
        </div>
    </h:body>

</html>
